package org.dbview.service.impl;

import java.math.BigDecimal;
import java.util.List;

import org.apache.log4j.Logger;
import org.dbview.dao.IDictionaryRelationMapper;
import org.dbview.model.TDictionaryRelation;
import org.dbview.service.IDictionaryRelationService;
import org.springframework.beans.factory.annotation.Autowired;

public class DictionaryRelationServiceImpl implements
		IDictionaryRelationService {
	private static Logger logger = Logger.getLogger(DictionaryRelationServiceImpl.class);
	
	@Autowired
	private IDictionaryRelationMapper dictionaryRelationMapper;

	@Override
	public List<TDictionaryRelation> getListByModuleId(BigDecimal moduleId) {
		try { 
			return dictionaryRelationMapper.findItByModuleId(moduleId);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			return null;
		}
	}

	@Override
	public Integer addRelation(
			TDictionaryRelation tDictionaryRelation) {
		try {
			return dictionaryRelationMapper.insertRelation(tDictionaryRelation);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			return null;
		}
	}

	@Override
	public Integer delRelation(TDictionaryRelation tDictionaryRelation) {
		try{
			return dictionaryRelationMapper.deleteRelation(tDictionaryRelation);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			return null;
		}
	}

}
